<template>
	<view class="content">
		<view>
			<view style="font-size: 25px;">已有用户信息</view>
			<view v-for="(item,index) in customers" :key="index" style="margin-bottom: 5px;">
				<uni-lst>
					<uni-list-item :title="item.cusname"  rightText="详细信息/操作" :thumb="src[index]">
						<template slot="footer" @click="getClicked(item.telenumber)">
							<uni-icons type="arrowright" color="#8F8F94"></uni-icons>
						</template>
					</uni-list-item>
					<uni-list-item title="联系用户">
						<template slot="footer">
							<image class="img" src="@/static/tele.png" @click="makeCall(item.telenumber)"></image>
							<img class="img" src="@/static/wechat.png" @tap="sendWXmsg">
						</template>
					</uni-list-item>
				</uni-lst>
			</view>
		</view>
		<!-- 不打算支持商家新增用户 -->
		<!-- 后面看需求 -->
		<!-- <view>
			<navigator class="navigator" url="../tabBar/customer/more/more">新增用户</navigator>
		</view> -->
		<view class="uni-list me-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @tap="bindSetting">
				<view class="uni-media-list uni-list-cell-navigate uni-navigate-right">
					<image class="uni-media-list-logo" src="../../../static/shezhi.png"></image>
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top me-list-setting">设置</view>
					</view>
				</view>
			</view>
		</view>

		<view style="height: 50px;"> </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				customers: [

				],
				src: [],
				index: -1
			};
		},
		methods: {
			bindSetting() {
				console.log("here")
				uni.navigateTo({
					url: '../../pages/denglu/logout/logout',
					fail(e) {
						console.log(e)
					}
				})
			},
			makeCall(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber: phoneNumber,
					success() {
						console.log("call");
					}
				})
			},
			sendWXmsg() {
				console.log("send a msg");
			},
			getClicked(telenumber) {
				console.log(telenumber);
				uni.navigateTo({
					url: '/pages/tabBar/customer/more/more',
					success: (res) => {
						res.eventChannel.emit('getCustomerOrderList', {
							telenumber: telenumber
						});
					}
				})
			}
		},
		created() {
			this.$myRequest({
				url: '/users/get_customer_info/'
			}).then(response => {
				this.customers = response.data;
				for (let i in response.data) {
					//奇怪的遍历方式。。。
					if (this.customers[i]['cuswxicon'] != '' && this.customers[i]['cuswxicon'] != null) {
						this.src.push(this.customers[i]['cuswxicon']);
					} else {
						this.src.push('../../../../../static/mine/user.png');
					}
				}
				console.log(this.src)
			})
		}
	}
</script>

<style lang="scss">
	.img {
		height: 20px;
		width: 20px;
		margin-right: 5px;
	}

	.navigator {
		width: 375px;
		height: 100px;
		border-radius: 40px;
		background-color: blue;
		font-size: 30px;
		color: #fff;
		text-align: center;
		line-height: 100px;
		margin-top: 20px;
	}
</style>
